package com.hspedu.map_;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

@SuppressWarnings({"all"})
public class MapEx01 {
    public static void main(String[] args) {
        HashMap hashMap = new HashMap();
        Employ jack = new Employ("jack", 19000, 1223);
        Employ merry = new Employ("merry", 20000, 1224);
        Employ ray = new Employ("ray", 15000, 1225);
        hashMap.put(1223,jack);
        hashMap.put(1224,merry);
        hashMap.put(1225,ray);
        System.out.println(hashMap.toString());
//        Set entrys = hashMap.entrySet();
//        Iterator iterator = entrys.iterator();
//        while (iterator.hasNext()) {
//            Object entry = iterator.next();
//            Map.Entry e = (Map.Entry)entry;
//            Object key = e.getKey();
//            Object value = e.getValue();
//            Employ p = (Employ) value;
//            if(p.getWage() > 18000){
//                System.out.println(value);
//            }
//        }

        Set set = hashMap.keySet();
        for(Object key:set){
            Employ p = (Employ) hashMap.get(key);
            if(p.getWage() > 18000){
                System.out.println(hashMap.get(key));
           }
        }
    }
}

class Employ{
    private String name;
    private double wage;
    private int id;

    public Employ(String name, double wage, int id) {
        this.name = name;
        this.wage = wage;
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getWage() {
        return wage;
    }

    public void setWage(double wage) {
        this.wage = wage;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Override
    public String toString() {
        return "Employ{" +
                "name='" + name + '\'' +
                ", wage=" + wage +
                ", id=" + id +
                '}';
    }
}